#include<iostream>
#include<vector>
#include<queue>
#include<cstring>
#include<cmath>
#include<map>
#include<set>
#include<cstdio>
#include<algorithm>
#define debug(a) cout<<#a<<"="<<a<<endl;
using namespace std;
const int maxn = 13;
typedef long long LL;
const int mod = 1e9 + 7;
inline LL read() {
    LL x = 0, f = 1; char ch = getchar();	while (!isdigit(ch)) { if (ch == '-') f = -1; ch = getchar(); }while (isdigit(ch)) { x = x * 10 + ch - 48; ch = getchar(); }
    return x * f;
}
LL a[maxn], tot = 0;
struct Node {
    LL cnt, sum;
    Node(LL _cnt = 0, LL _sum = 0)
        :cnt(_cnt)
        , sum(_sum)
    {}
    void Add(int t, const Node& A) {
        sum = (sum + A.sum % mod) % mod;
        sum = (sum + A.cnt * t % mod) % mod;
        cnt = (cnt + A.cnt) % mod;
    }
    void operator=(const Node& A) {
        sum = A.sum;
        cnt = A.cnt;
    }
}dp[maxn][maxn];
int vis[maxn][maxn];
Node dfs(LL pos, LL pre, bool lead, bool limit) {
    if (pos == 0) return Node(1, 0);
    if (!limit&&vis[pos][pre]!=-1) return dp[pos][pre];
    LL bound = (limit ? a[pos] : 9);
    Node ans;
    for (LL i = 0; i <= bound; i++) {
        if (lead && i == 0) {
            ans.Add(0, dfs(pos - 1, i, 1, i == bound && limit));
        }
        else if (lead && (i != 0)) {
            ans.Add(i, dfs(pos - 1, i, 0, i == bound && limit));
        }
        else {
            ans.Add(i, dfs(pos - 1, i, 0, i == bound && limit));
        }
    }
    if (!limit && !lead) {
        dp[pos][pre] = ans;
        vis[pos][pre] = 1;
    }
    return ans;
}
inline LL solve(LL x) {
    tot = 0;
    while (x) {
        a[++tot] = x % 10; x /= 10;
    }
    return dfs(tot, 0, 1, 1).sum;
}
int main(void) {
    int q; scanf("%d", &q);
    while (q--) {
        memset(vis, -1, sizeof(vis));
        LL l, r; l = read(); r = read();
        printf("%lld\n", (solve(r) - solve(l - 1)) % mod);
    }
    return 0;
}
